<?php


namespace app\admin\controller;


use easyadmin\app\columns\lists\ListDateTime;
use easyadmin\app\columns\lists\ListText;
use easyadmin\app\libs\ListField;
use easyadmin\app\libs\Page;
use think\db\Query;

/**
 * 单个用户账户信息
 * Class UserAccount
 * @package app\admin\controller
 */
class UserAccount extends Admin
{
    protected $tableName = 'user_account';
    protected $pageName = '账户详情';
    protected $disabledAction = ['new', 'show', 'edit', 'delete'];

    protected function configListJoin(Page $page, Query $query, string $alias)
    {
        $query->join('user ', 'user.id='. $alias .'.user_id');
    }

    protected function configListField(ListField $list)
    {
        $list
            ->addField('id', '账户ID', ListText::class)
            ->addField('user.real_name', '用户名', ListText::class)
            ->addField('balance', '用户可用余额', ListText::class)
            ->addField('frozen_balance', '冻结余额', ListText::class)
            ->addField('total', '总收益', ListText::class)
            ->addField('total_task_profit', '任务累计收益', ListText::class)
            ->addField('total_popularize_profit', '推广累计收益', ListText::class)
            ->addField('team_profit', '团队累计收益', ListText::class)
            ->addField('recharge_profit', '充值累计金额', ListText::class)
            ->addField('update_time', '更新时间', ListDateTime::class)
            ->addField('remark', '备注', ListText::class)
        ;
    }
    protected function configListWhere(Page $page, Query $query, $alias)
    {
        $userId = input('id');
        $query->where(['user_id' => $userId]);
    }

}